package com.itranswarp.learnjava;

import java.util.Scanner;

/**
 * switch实现石头/剪子/布并判断胜负
 */
public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		System.out.println("please choice:");
		System.out.println(" 1: Rock");
		System.out.println(" 2: Scissors");
		System.out.println(" 3: Paper");
		// 用户输入:
		System.out.println("请输入1.石头，2.剪刀，3.布：");
		int choice = input.nextInt();
		// 计算机随机数 1, 2, 3:
		int random = 1 + (int) (Math.random() * 3);
		switch (choice) {
			case 1:
				if(random==1){
					System.out.println("系统出的石头！");
					System.out.println("平局！");
				}else if (random==2) {
					System.out.println("系统出的剪刀！");
					System.out.println("你赢了！");
				}else {
					System.out.println("系统出的布！");
					System.out.println("你输了！");
				}
				break;
			case 2:
				if(random==1){
					System.out.println("系统出的石头！");
					System.out.println("你输了！");
				}else if (random==2) {
					System.out.println("系统出的剪刀！");
					System.out.println("平局！");
				}else {
					System.out.println("系统出的布！");
					System.out.println("你赢了！");
				}
				break;
			case 3:
				if(random==1){
					System.out.println("系统出的石头！");
					System.out.println("你赢了！");
				}else if (random==2) {
					System.out.println("系统出的剪刀！");
					System.out.println("你输了！");
				}else {
					System.out.println("系统出的布！");
					System.out.println("平局！");
				}
				break;
			default:
				System.out.println("请输入正确的数字(1.石头，2.剪刀，3.布)！");
				break;
		}
	}

}
